<?php

namespace App\Admin\Actions\UserAction;

use Encore\Admin\Facades\Admin;
use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;

class RestorePasswordChance extends RowAction
{
    public $name = '恢复密码重置';

    public function handle(Model $model)
    {
	    if (!in_array(Admin::user()->id, [1,3])) {
		    return $this->response()->error('无权操作')->refresh();
	    }

	    $model->update(['password_reset_sms_at' => null]);

	    return $this->response()->success('密码重置已恢复')->refresh();
    }

	public function dialog()
	{
		$this->confirm('确定恢复当前账号密码重置?');
	}
}
